package com.heima.dome1;

import com.heima.domain.Students;

import java.util.Comparator;
import java.util.TreeSet;

public class TestStudentscore {
    public static void main(String[] args) {
        TreeSet<Students> ts=new TreeSet<>(new Comparator<Students>() {
            @Override
            public int compare(Students o1, Students o2) {
                int result= (int) (o2.getScore()-o1.getScore());
                result=result==0?o1.getAge()-o2.getAge():result;
                return result;
            }
        });

        Students s1=new Students("liusan",20,90.0);
        Students s2=new Students("lisi",22,90.0);
        Students s3=new Students("wangwu",20,99.0);
        Students s4=new Students("sunliu",22,100.0);

        ts.add(s1);
        ts.add(s2);
        ts.add(s3);
        ts.add(s4);

        System.out.println(ts);
    }
}
